﻿/**************************************************************
 *
 * 唯一标识：4dc15b23-3d1a-4390-9b60-8141360dce03
 * 命名空间：Sgr.UPMS.Domain.Departments
 * 创建时间：2023/8/27 19:41:54
 * 机器名称：DESKTOP-S0D075D
 * 创建者：antho
 * 电子邮箱：fengqinhua2016@163.com
 * 描述：
 *
 **************************************************************/

using Sgr.Domain.Entities;
using Sgr.Domain.Managers;
using Sgr.UPMS.Domain.Menus;
using Sgr.UPMS.Domain.Organizations;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Sgr.UPMS.Domain.Departments
{
    public interface IDepartmentManage : ITreeNodeManage<Department, long>
    {
        /// <summary>
        /// 创建一个新的部门实体
        /// </summary>
        /// <param name="name"></param>
        /// <param name="orderNumber"></param>
        /// <param name="entityStates"></param>
        /// <param name="remarks"></param>
        /// <param name="managerUserId"></param>
        /// <param name="leader"></param>
        /// <param name="phone"></param>
        /// <param name="email"></param>
        /// <param name="orgId"></param>
        /// <param name="parentId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<Department> CreateNewAsync(string name,
            int orderNumber,
            EntityStates entityStates,
            string? remarks,
            long? managerUserId,
            string? leader,
            string? phone,
            string? email,
            long orgId,
            long? parentId,
            CancellationToken cancellationToken = default);

        /// <summary>
        /// 验证同级部门名称是否唯一
        /// </summary>
        /// <param name="orgId">组织ID</param>
        /// <param name="name">部门名称</param>
        /// <param name="parentId">父级部门ID</param>
        /// <param name="excludeId">需要排除的部门ID</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>业务规则检查结果</returns>
        Task<DomainRuleCheckResult> ValidateNameUniquenessAsync(
              long orgId,
              string name,
              long parentId,
              long? excludeId = null,
              CancellationToken cancellationToken = default);

        /// <summary>
        /// 激活部门及其子部门
        /// </summary>
        /// <param name="department">部门</param>
        /// <param name="cancellationToken">取消令牌</param>
        Task ActivateAsync(Department department, CancellationToken cancellationToken = default);

        /// <summary>
        /// 停用部门及其子部门
        /// </summary>
        /// <param name="department">部门</param>
        /// <param name="cancellationToken">取消令牌</param>
        Task DeactivateAsync(Department department, CancellationToken cancellationToken = default);
    }
}